﻿#ifndef DRILLINGRIG_H
#define DRILLINGRIG_H

#include "Drillingrig_global.h"
#include "Plugins/PluginsManager.h"


class PluginsManager;
class DrillingrigEvent;
class DrillingrigMediator;
class ControlBridge;
class ModbusClientProxy;

class DRILLINGRIG_EXPORT Drillingrig : public QObject {
    Q_OBJECT
public:
    Drillingrig(QQmlContext* context, QObject* parent = nullptr);
	~Drillingrig();
	void setBridge(QJsonObject const& obj);

	void setIOAction(EquipmentAction* action);

	void setModbus(QJsonObject const& obj);
signals:
	void loadFinished();
	void errorText(QString text);
private:
	QThread* m_asyncBridge = nullptr;
	QThread* m_asyncModbus = nullptr;
	PluginsManager* m_pluginsManager = nullptr;
	DrillingrigEvent* m_interaction = nullptr;
	DrillingrigMediator* m_mediator = nullptr;       //注意声明顺序，中介模块中包含同步和异步的释放工作，要保证到最后释放
	ControlBridge* m_bridge = nullptr;
	ModbusClientProxy* m_modbus = nullptr;
};

#endif // DRILLINGRIG_H
